package com.example.SearchAmbitus.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.example.SearchAmbitus.R;
import model.LocationManager;

/**
 * Created by Bxh on 2014/11/26.
 */
public class SearchActivity extends Activity {
    private Button btn_search_goBack;
    private Button btn_search_btnSearch;

    private TextView editText_search;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_search);

        btn_search_goBack = (Button) findViewById(R.id.btn_search_goBack);
        btn_search_btnSearch = (Button) findViewById(R.id.btn_search_btnSearch);
        editText_search = (TextView) findViewById(R.id.editText_search);
        //返回
        btn_search_goBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SearchActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });
        //搜索
        btn_search_btnSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = editText_search.getText().toString();

                LocationManager locationManager = new LocationManager();
                double lat = locationManager.getLat();
                double lon = locationManager.getLon();

                Intent intent = new Intent(SearchActivity.this,POIListActivity.class);
                intent.putExtra("name",name);
                intent.putExtra("lat",lat);
                intent.putExtra("lon",lon);
                startActivity(intent);
            }
        });
    }
}
